﻿Rijschool.agenda = function (params)
{	
    var viewModel =
    {
        navItems: [{ text: "Betalingen en meer", icon: "money" }, { text: "Log uit", icon: "close" }],
        titel		: ko.observable('Agenda!'),
        arrayEv: [],
      
		navigate 	: function(e)
		{
			var text = e.itemData.text;
			if(text == "Betalingen en meer")
			{
			    Rijschool.app.navigate("betalingen/");
			}
			else if (text == "Log uit")
			{
				Rijschool.app.navigate("inlog/");
			}
		},
		createCalendar	: function()
		{
			 $("#calendar").fullCalendar({
					header: 
					{
						left: 'prev,next today',
						center: 'title',
						right: 'month,agendaWeek,agendaDay'
					},
					editable: true,
					theme: true,
					buttonIcons: 
					{
						prev: 'circle-triangle-w',
						next: 'circle-triangle-e'
					},
					eventSources:
                     [
                         {
                             events: this.arrayEv,
                         }
                     ],
					eventClick: function(calEvent, jsEvent, view) 
					{
						
					},
					dayClick: function(date, allDay, jsEvent, view) 
					{
				
						Rijschool.app.navigate("nieuweAfspraak/"+ date);
				
					}
				});
		},
		
		LaadCalendar: function (test)
		{
		    var d = window.location.host;
		    viewModel.arrayEv = JSON.parse(httpGet("http://" + d + "/Site/backend/index.php?agenda"));
		    viewModel.createCalendar();
		},
    };
    return viewModel;
};




